<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>

    // 造车厂

    // 工厂模式
    function CreateCar(color, type, brand){
        this.color = color;
        this.type = type;
        this.brand = brand;
        this.run = function(){
            console.log(`${this.color}的${this.brand}${this.type}跑起来了`);
        }
    }

    const c1 = new CreateCar("红色","跑车","大众");
    const c2 = new CreateCar("白色","SUV","五菱");
    const c3 = new CreateCar("黑色","轿车","比亚迪");
    console.log(c1);
    console.log(c2);
    console.log(c3);
    c1.run();
    c2.run();
    c3.run();

    // 需求：一个比亚迪轿车的订单，100辆，包含（黑色和白色）

    function createBYD(color){
        return new CreateCar(color,"轿车","比亚迪");
    }

    const byd1 = new createBYD("白色");
    const byd2 = new createBYD("黑色");
    console.log(byd1);
    console.log(byd2);
    byd1.run();
    byd2.run();

    
</script>
</html>